#pragma once

#include "land_ogl.h"
#include "GL/glew.h"

typedef struct {
	LandCanvas canvas;
	GLuint fboDraw;
	GLuint texDraw;
	GLuint fboRead;
	GLuint texRead;
	GLuint texDepth;
	GLuint rbo;
}LandOglCanvas;

typedef struct {
	LandShader shader;
	GLuint program;
	GLint projPos;
	GLint viewPos;
	GLint transformPos;
}LandOglShader;

typedef struct {
	LandTexture tex;
	GLuint glId;
	int upload;
}LandOglTexture;

typedef struct {
	LandVertex vertex;
	GLuint glVao;
	GLuint glVbo;
	GLuint glIbo;
	int created;
}LandOglVertex;

LandCanvasBackend*
landGetOglCanvasBackend();
void
landBindOglCanvas(LandCanvas* canvas);
GLuint
landGetOglCanvasTexId(LandCanvas* canvas);

LandDrawBackend*
landGetOglDrawBackend();
int
landInitOglDrawContext(LandGraphics* config, LandOgl* oglConfig);

LandShaderBackend*
landGetOglShaderBackend();
void
landBindOglShader(LandCanvas* canvas, LandDraw* draw);

LandStdBackend*
landGetOglStdBackend();
void
landInitOglStdContext(LandGraphics* config, LandOgl* oglConfig);

LandTextureBackend*
landGetOglTextureBackend();
GLuint
landGetOglTextureId(LandTexture* tex);

LandVertexBackend*
landGetOglVertexBackend();
void
landBindOglVertex(LandVertex* vertex);